package pers.xukai.fullMark.entity.vo;

import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import pers.xukai.common.utils.Assert;
import pers.xukai.fullMark.entity.po.Todo;

import java.util.Date;

/**
 * @author 殷绪凯
 * @datetime 2022年 11月 29日 21:21
 */
@Data
@ToString
@ApiModel("todo保存vo")
public class SaveTodoVo {

    @ApiModelProperty("标题")
    private String title;

    @ApiModelProperty("描述")
    private String todoDesc;

    @ApiModelProperty("用户id")
    private String userId;

    @ApiModelProperty("提醒时间")
    @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss", timezone="GMT+8")
    private Date noticeTime;

    @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss", timezone="GMT+8")
    @ApiModelProperty("开始时间")
    private Date todoStartTime;

    @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss", timezone="GMT+8")
    @ApiModelProperty("结束时间")
    private Date todoEndTime;

    @ApiModelProperty("是否发送消息")
    private boolean sendMsg;

    /**
     * 创建todo实体
     * @return
     */
    public Todo createTodo() {
        return new Todo(null, title, todoDesc, userId, todoStartTime, todoEndTime, null,noticeTime, sendMsg, false, false, new Date(), null);
    }

    public void check(){
        Assert.isNotNull(title,"标题")
                .and(todoDesc,"描述")
                .and(userId,"用户ID")
//                .and(todoStartTime,"开始时间")
//                .and(todoEndTime,"结束时间")
                .and(sendMsg,"是否发送消息");
        if (sendMsg){
            Assert.isNotNull(noticeTime,"提醒时间");
        }
        if (ObjectUtil.isNotNull(noticeTime)){
            sendMsg = true;
        }
    }
}
